package org.lzy.shop.adapter

import android.content.Context
import android.view.ViewGroup
import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder
import org.lzy.shop.R
import org.lzy.shop.response.OrderInfoResponse
import org.lzy.shop.util.setUrlRound

class OrderSpecAdapter(): BaseQuickAdapter<OrderInfoResponse.GoodsListBean, QuickViewHolder>()  {

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): QuickViewHolder {
        return QuickViewHolder(R.layout.item_spec_shop, parent)
    }

    override fun onBindViewHolder(holder: QuickViewHolder, position: Int, item: OrderInfoResponse.GoodsListBean?) {
        item?.let {
            if (item.spec?.images!!.isNotEmpty()) {
                setUrlRound(item.spec?.images?.get(0),10f,holder.getView(R.id.item_spec_pic))
            }else{
                setUrlRound(item.goodsInfo?.mainPic,10f,holder.getView(R.id.item_spec_pic))
            }
            holder.setText(R.id.item_spec_title, item.spec?.name)
            holder.setText(R.id.item_spec_price, item.spec?.price)
            holder.setText(R.id.item_spec_number, "x"+ item.count)

        }

    }
}